<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function myAxios() {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            // resolve("promise成功");
            reject("错误了");
          }, 1000);
        });
      }

      let p1 = myAxios();
      let p2 = p1
        .then((res) => {
          console.log(res);
          return [null, 999];
        })
        .catch((err) => {
          console.log(err);
          return [1000, null];
        });

      p2.then((res) => {
        let [err, data] = res;
        if (err) console.log(err);
        else console.log(data);
      });
    </script>
  </body>
</html>
